﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head lang="en">
	<meta http-equiv="content-type" content="text/html;charset=utf-8">
	<title>SmallBackend Documentation</title>
	<!-- Framework CSS -->
	<link rel="stylesheet" href="assets/blueprint-css/screen.css" type="text/css" media="screen, projection">
	<link rel="stylesheet" href="assets/blueprint-css/print.css" type="text/css" media="print">
	<!--[if lt IE 8]><link rel="stylesheet" href="assets/blueprint-css/ie.css" type="text/css" media="screen, projection"><![endif]-->
	<link rel="stylesheet" href="assets/blueprint-css/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">
	<style type="text/css" media="screen">
		p, table, hr, .box { margin-bottom:25px; }
		.box p { margin-bottom:10px; }
	</style>
</head>


<body>
	<div class="container">
	
		<h1 class="center">smallBackend</h1>
		
		<hr>
		
		<h2 id="toc" class="alt">Table of Contents</h2>
		<ol class="alpha">
			<li><a href="#introduction">Introduction</a></li>
			<li><a href="#loader">Load the Stub Loader</a></li>
			<li><a href="#options">Options.php, set up the Backend</a></li>
			<li><a href="#functions">Functions, what you use to get the saved data</a></li>
			<li><a href="#options_meta">Options_meta, the Backend's settings</a></li>
			<li><a href="#css">CSS Files and Structure</a></li>
		</ol>
		
		<hr>
		
		<h3 id="introduction"><strong>A) Introduction</strong> - <a href="#toc">top</a></h3>
		<p>The intention of this backend is to provide an easy to intergrate and user-friendly solution for website management.</p>
		
		<p>In general the startup process follows as such</p>
		
		<ol>
			<li>Upload files from 'Production' folder to root of website, the folder 'admin' should remain intact</li>
			<li>Edit 'admin/options.php', select which elements you will need and edit appropriately</li>
			<li>Edit 'admin/options_meta.php' to configure the backend's name, the username and password, changing the password is extremely important</li>
			<li>Intergrate the backend with the frontend using the provided <a href="#functions">Functions</a> which can be used after loading 'stub_loader.php'</li>
			<li>Optionaly customize the <a href="#css">CSS</a> to match the frontend</li>
			
		</ol>

		<hr>
		<h3 id="loader"><strong>B) Loading the stub loader</strong> - <a href="#toc">top</a></h3>

		<p>At bare minimum the backend must be initialized by adding the following php code to the begining of any frontend page that will utilize the backend. </p>
		<pre>
	include 'stub_loader.php';
		</pre>
		<p>This assumes that you have included the stub loader in the same directory as the calling file and that the admin folder is located, again, in the same directory as the calling file. That is that the folder containing hte calling page looks something like thus.
		<pre>
	| calling file
	| stub_loader.php
	| --admin
		| The contents of the admin folder
		</pre>
		<p>Provided that the contents of 'admin' folder have not been removed the the 'admin' folder it is safe to move the 'admin' folder anywhere provided that 'stub_loader.php' is edited so that it points to the new location.</p>
		<p>Put another way this means that the contents of 'admin' folder, files which provide all necicary functions for smallBackend, do not assume any particular relative to either the calling or stub loader.</p>		
		<hr>
		
		<h3 id="options"><strong>C) Options.php, set up the Backend</strong> - <a href="#toc">top</a></h3>
		<p>SmallBackend use 'options.php', found in the root of 'admin' folder, to generate the options presented to the admin. By default 'options.php' contains examples for all html 'input' elements which can be easily customised.</p>
		<p>For esample say we wanted to allow a client to edit the main box of text on the home page;</p>
		<pre>
	&lt;!--&nbsp;Example&nbsp;of&nbsp;a&nbsp;multi-line&nbsp;text&nbsp;area,&nbsp;works&nbsp;much&nbsp;the&nbsp;same&nbsp;as&nbsp;the&nbsp;text&nbsp;field&nbsp;--&gt;
	&lt;tr&gt;
	&lt;td&gt;&quot;<span style="color:red">Describe&nbsp;yourself&quot;&nbsp;area&nbsp;by&nbsp;the&nbsp;large&nbsp;homepage&nbsp;image</span>&lt;/td&gt;
	&lt;td&gt;&lt;textarea&nbsp;rows=&quot;<span style="color:blue">3</span>&quot;&nbsp;name=&quot;<span style="color:green">description</span>&quot;&nbsp;class=&quot;<span style="color:blue">full_width</span>&quot;&gt;
	&lt;?php&nbsp;echo&nbsp;htmlspecialchars($settings[&quot;<span style="color:green">description</span>&quot;]);?&gt;
	&lt;/textarea&gt;&lt;/td&gt;
	&lt;/tr&gt;
		</pre>
		<p>The <span style="color:green">green</span> text, in this case "description" is very important and must be unique for every element of options.php otherwise it would be impossible for smallBackend to know which element's value you wanted returned when you call a function.</p>
		<p>The <span style="color:red">red</span> text is the what is shown to the admin to describe the option, in this case it tells him where this text is going to be displayed.</p>
		<p><span style="color:blue">Blue</span> text deals with presentation in the backend, 'full_width' is a CSS class that makes the text field expand the full width of the table and '3' says how high the box should be.</p>
		<p>All options can be altered in a similar method although some such as a dropdown list or a radio selector both at minimum require the 'name' and the 'value' to be altered.</p>
		<hr>
		
		<h3 id="functions"><strong>D) Functions, what you use to get the saved data</strong> - <a href="#toc">top</a></h3>
		<p>Once you have successfully loaded the stub loader you can use the following functions to access the data:</p>
		<h3>echo_setting($key)</h3>
		<p>'echo_setting()' is the work horse of smallBackend functions. It does just as the name says it does, an example of usage based on the example in the preceding 'options.php' section:</p>
		<pre>
	echo_setting('description');</pre>
		<p>Will print the value of 'description', for instance if we had wrote and saved "I am the best" in the backend and then called this function then it would print "I am the best".</p>
	
		<h3>is_true($key)</h3>
		<p>'is_true()' is called much like the last function only instead of echoing/printing the value of the setting it instead does a boolean check, usefull with checkboxes and really any if statement. Example: </p>
		<pre>
	if(is_true('description'))</pre>
		<p>Will return with tue or false depending on the value of 'description', will return false if 'description' is empty or has not been saved.</p>
		
		<h3>get_setting($key)</h3>
		<p>'get_setting()' is basicly the same as 'echo_setting' the only difference being that instead of echoing/printing the value it will return the value. Use it if you want to do something special with the value instead of simply echoing it.</p>
		<pre>
	$var = get_setting('description');</pre>
		<p>Will return the value of 'description'.</p>
		
		<h3>set_setting($key, $new_value)</h3>
		<p>To change the value of a setting 'set_setting()' can be used. It takes to arguments, the first of which is the same as the other functions the second of which is the setting's new value.</p>
		<pre>
	set_setting('description', 'is > 9000');</pre>
		<p>The value will then be changed and saved,</P>
		<hr>
		
		<h3 id="options_meta"><strong>E) Options_meta, the Backend's settings</strong> - <a href="#toc">top</a></h3>

		<p>In order for your website to enjoy any level of security you must change the password and or the username from the default. This can be done using 'options_meta.php'. An example of a different username and password:</p>
		<pre>
	$password = "<span style="color:blue">i_am_a_fool</span>";
	$user = "<span style="color:blue">insecure</span>";</pre>
		<p>Change the portions coloured <span style="color:blue">blue</span></p>
		<p>Options_meta also allows you to change the name used in the header and page titile:</p>
		<pre>
	$backend_name = "<span style="color:blue">Best admin page ever!</span>";</pre>
		<p>Again only change the <span style="color:blue">blue</span> text.</P>
		<hr>
		
		<h3 id="css"><strong>F) CSS, Appearance and Backend Layout</strong> - <a href="#toc">top</a></h3>

		<p>EasyBackend uses a number of CSS stylesheets all of which can be found by inspecting 'main.css'. Style.css contians the base CSS rules while the theme files contain rules related to specific appearance</p>
		<p>The CSS related to theming can be found in two files, theme_1.css and theme_2.css, try each of these styles and find which one fits best with the frontend. Should you want to change the backend's colors do so in these files.</p> 

		<p>To switch between the two themes alternate which theme's import line is commented out:</p>  
		<p>If you would like to edit the color, font, or style of any elements in one of these columns, you would do the following:</p>
		<pre>
	@import url("theme_2.css");
	/*@import url("theme_2.css");*/
		</pre>

		<hr>
		
		<p><a href="#toc">Go To Table of Contents</a></p>
		
		<hr class="space">
	</div><!-- end div .container -->
</body>
</html>